<?php

class Kantor{
	
	private $kd_kantor;
	private $kd_provinsi;
	private $alamat;
	private $kota;
	private $telp;
	private $faks;
	
	function __construct(){}
	
	function setKd_kantor($kd_kantor){
		$this->kd_kantor = $kd_kantor;
	}
	
	function setKd_provinsi($kd_provinsi){
		$this->kd_provinsi = $kd_provinsi;
	}
	
	function setAlamat($alamat){
		$this->alamat = $alamat;
	}
	
	function setKota($kota){
		$this->kota = $kota;
	}
	
	function setTelp($telp){
		$this->telp = $telp;
	}
	
	function setFaks($faks){
		$this->faks = $faks;
	}
	
	function getKd_kantor(){
		return $this->kd_kantor;
	}
	
	function getKd_provinsi(){
		return $this->kd_provinsi;
	}
	
	function getAlamat(){
		return $this->alamat;
	}
	
	function getKota(){
		return $this->kota;
	}
	
	function getTelp(){
		return $this->telp;
	}
	
	function getFaks(){
		return $this->faks;
	}

}

class Daftar_Kantor{

	function get(){
	
		$sql="select * from kantor limit 1";     
        $data = mysql_query($sql);
		$kantor=false; 
		if($data){
				while($row = mysql_fetch_assoc($data)){
						$kantor = new Kantor();
						$kantor->setKd_kantor($row['kd_kantor']);
						$kantor->setKd_provinsi($row['kd_provinsi']);
						$kantor->setAlamat($row['alamat']);
						$kantor->setKota($row['kota']);
						$kantor->setTelp($row['telp']);
						$kantor->setFaks($row['faks']);		
				}
		}       
		return $kantor;
	}
	
	function getById($kd_kantor)
	{
		$sql="select * from provinsi where kd_kantor='$kd_kantor'";
		$kantor=false;            
                $data = mysql_query($sql);
                if($data){
                        while($row = mysql_fetch_assoc($data)){
                                $kantor = new Kantor();
								$kantor->setKd_kantor($row['kd_kantor']);
								$kantor->setKd_provinsi($row['kd_provinsi']);
								$kantor->setAlamat($row['alamaat']);
								$kantor->setKota($row['kota']);
								$kantor->setTelp($row['telp']);
								$kantor->setFaks($row['faks']);
								
                        }
                }       
                return $kantor;

	
	}
	
	function edit(Kantor $kantor){
		$sql="
			UPDATE kantor set
			kd_provinsi = '".$kantor->getKd_provinsi()."',
			alamat = '".$kantor->getAlamat()."',
			kota = '".$kantor->getKota()."',
			telp = '".$kantor->getTelp()."',
			faks = '".$kantor->getFaks()."'
			WHERE
			kd_kantor = '".$kantor->getKd_kantor()."'
		";
		
		$query = mysql_query($sql);
		return $query;
	
	}

}



